package com.taotao.search.exception;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

public class GlobalExceptionResolver implements HandlerExceptionResolver {

	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object obj,
			Exception e) {
		//1.日志写入日志文件中
		System.out.println(e.getMessage());
		e.printStackTrace();
		//2.及时给开发人员发短信，邮件
		System.out.println("短信");
		//设置试图信息
		ModelAndView model = new ModelAndView();
		model.setViewName("error/exception");
		model.addObject("message","你的网络环境异常请稍后再试");
		return model;
	}

}
